package skipList_02;

import helper_ds.DS_HashMap;

import java.util.Map;


/**
 * File: SkipListTest.java
 * @author Tobias Hardes
 *
 */
public class Main {
	public static void main(String args[]) {
		args = new String[] { "1", "5", "3", "4" };
		DS_HashMap hMap = new DS_HashMap();
		//hMap.generateStaticMap();
		Map<Number, Number> map = hMap.getMap();
		SkipList L = new SkipList();
		SkipListProof proofGen = new SkipListProof();
		SkipList proof;
		long start = System.currentTimeMillis();
		for (int i = 0; i < map.size(); i++) {
			int key = Integer.parseInt(map.get(i).toString());
			L.insert(key);
			L.printList();
			L = SkipListAuthentication.calculateAuthentication2(L);
			proof =proofGen.generateProof(L,Integer.parseInt(map.get(i).toString())); 
			System.out.println("------");
		}
		/*long end = System.currentTimeMillis();
		System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++");
		System.out.println(end-start);
		System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++");*/
		L.printList();
		SkipListNode p = null;
		for (int i = 0; i < map.size(); i++) {
			int key = Integer.parseInt(map.get(i).toString());
			 p = L.search(key).getNd();
			if (p != null)
				System.out.println("Key: " + key + " found.");
			else
				System.out.println("Key: " + key + " not found.");
		}

		int key = general_algorithms.RandomNumber.randint();
		try
		{
			 p = L.search(key).getNd();
		}
		catch(NullPointerException e)
		{
			p = null;
		}
		if (p != null)
			System.out.println("key: " + key + " found.");
		else
			System.out.println("key: " + key + " not found.");

		key = Integer.MAX_VALUE;
		p = L.search(key).getNd();
		if (p != null)
			System.out.println("key: " + key + " found.");
		else
			System.out.println("key: " + key + " not found.");

		key = Integer.MIN_VALUE;
		try
		{
			 p = L.search(key).getNd();
		}
		catch(NullPointerException e)
		{
			p = null;
		}
		if (p != null)
			System.out.println("Key: " + key + " found.");
		else
			System.out.println("Key: " + key + " not found.");
	}
}
